<template>
  <div>
    <el-dialog title="角色分配" :visible.sync="dialogVisible" width="400px">
      <el-form ref="form" :model="form" label-width="100px">
        <el-form-item label="分配角色">
          <el-select v-model="form.roleId" placeholder="请选择">
            <el-option
              v-for="item in roleList"
              :key="item.id"
              :label="item.name"
              :value="item.type"
            />
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submitHandle">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import crudUser from "@/api/system/user";
import { getToken } from "@/utils/auth";
import { Editor, Toolbar } from "@wangeditor/editor-for-vue";
import "@wangeditor/editor/dist/css/style.css";
export default {
  name: "JiaRenReportDialog",
  components: {
    Editor,
    Toolbar
  },
  props: {
    title: {
      type: String,
      default: "新增"
    },
    roleList: {
      type: Array
    }
  },
  dicts: ["ROLE"],
  data() {
    return {
      dialogVisible: false,
      isEdit: false, //是否编辑
      form: {
        id: "",
        roleId: "" //角色
      },
      editorConfig: {
        placeholder: "请输入内容...",
        maxLength: this.maxLength, // 限制富文本输入文本字数
        cityList: []
      }
    };
  },
  computed: {
    uploadUrl() {
      return process.env.VUE_APP_BASE_API + "/public/file/upload";
    },
    headers() {
      return { Authorization: getToken() };
    }
  },

  methods: {
    submitHandle() {
      crudUser
        .updateRole(this.form)
        .then(res => {
          this.dialogVisible = false;
          this.$notify({ message: "操作成功", type: "success" });
          this.$emit("submitSuccess");
        })
        .catch(() => {});
    }
  }
};
</script>

<style lang="scss"></style>
